import java.util.Scanner;

public class demo01 {
    //汽水瓶
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n;
        while ((n=sc.nextInt())!=0){
            int sum=func(n);
            System.out.println(sum);
        }
    }
    public static int func(int n){
        int sum=0;
        while (n>1){
            sum+=n/3;
            n=n/3+n%3;
            if(n==2){
                sum+=1;
                break;
            }
        }
        return sum;
    }
}
